package com.zh.webcommon.common.support.observer;

import com.google.common.eventbus.DeadEvent;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;

/**
 * 死信数据 Observer
 *
 * @author Zhou
 * @date 16:45 2023/12/24
 */
@Slf4j
public final class DeadEventObserver {
    private DeadEventObserver() {
    }

    static final DeadEventObserver defaultDeadEventObserver = new DeadEventObserver();

    @Subscribe
    public void receive(DeadEvent event) {
        log.debug("死信数据... event = " + event);
    }

    /**
     * 添加EventBus
     * 即，将自己注册到EventBus
     *
     * @param eventBus 事件总线
     */
    public static void observeEventBus(EventBus eventBus) {
        eventBus.register(defaultDeadEventObserver);
    }

}
